class Solution:
    def lengthOfLongestSubstring(self, s: str) -> int:
        i = 0
        j = 0
        n = len(s)
        hash_map = set()
        ans = 0
        while i < n and j < n:
            while s[j] in hash_map:
                hash_map.remove(s[i])
                i += 1
            ans = max(ans, j - i + 1)
            hash_map.add(s[j])
            j += 1
        return ans

if __name__ == '__main__':
    s = Solution()
    r = s.lengthOfLongestSubstring("abcabcbb")
    print(r)